#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n);

	int i;
	int hole;
	int sht;
	for (i = 1; i <= n; i++)
	{
		scanf("%6d%5d", &hole, &sht);
		printf("6%05d\n", sht);
	}
	return 0;
}